using System;
using Rhino.Mocks;
using Sedge.Core.FileSystemWrap;

namespace Sedge.Tests.App
{
	public class FakeFileSystem : IFileSystem
	{
		private IPathWrap _path;
		public IPathWrap Path
		{
			get
			{
				if (_path == null)
					_path = MockRepository.GenerateStub<IPathWrap>();
				return _path;
			}
		}

		private IFileWrap _file;
		public IFileWrap File
		{
			get
			{
				if (_file == null)
					_file = MockRepository.GenerateStub<IFileWrap>();
				return _file;
			}
		}

		private IDirectoryWrap _directoryWrap;
		public IDirectoryWrap Directory
		{
			get
			{
				if (_directoryWrap == null)
					_directoryWrap = MockRepository.GenerateStub<IDirectoryWrap>();
				return _directoryWrap;
			}
		}

		private IXmlFileSerializer _xmlFileSerializer;
		public IXmlFileSerializer XmlFileSerializer
		{
			get
			{
				if (_xmlFileSerializer == null)
					_xmlFileSerializer = MockRepository.GenerateStub<IXmlFileSerializer>();
				return _xmlFileSerializer;
			}
		}

		public FakeFileSystem FileAlwaysExists()
		{
			File.Stub(x => x.Exists(String.Empty)).IgnoreArguments().Return(true);
			return this;
		}

		public FakeFileSystem FileAlwaysMiss()
		{
			File.Stub(x => x.Exists(String.Empty)).IgnoreArguments().Return(false);
			return this;
		}

	}
}